// import { defineConfig } from 'vite'
// import vue from '@vitejs/plugin-vue'
//
// // https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [vue()]
// })


const path = require("path");
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import viteSvgIcons from 'vite-plugin-svg-icons';
// function resolve(dir) {
//   return path.join(__dirname, dir);
// }
const resolve = dir => path.resolve(__dirname, dir)
const config = {
  plugins: [
      vue(),
      viteSvgIcons({
        iconDirs: [path.resolve(process.cwd(), 'src/icons')],
        symbolId: 'icon-[dir]-[name]',
      })
  ],
  server: {
    hmr: true,
    proxy: {
      '/api': {
        target: 'https://www.hurdcloud.cn/pwgc-web-server',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  resolve: {
    alias: {
      "@": resolve("src"),
    },
  },
};
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  console.log(command);
  return {...config}
  // if (command == "serve") {
  //   config.server.port = 3001;
  //   return {
  //     ...config,
  //   };
  // } else {
  //   config.server.port = 3002;
  //   return {
  //     ...config,
  //   };
  // }
});
